//
//  RealNameViewController.m
//  project
//
//  Created by 张亚林 on 2017/11/7.
//  Copyright © 2017年 Macmini. All rights reserved.
//

#import "RealNameViewController.h"
#import "HWImagePickerSheet.h"
#import "NSString+STString.h"
@interface RealNameViewController ()<UITableViewDataSource,UITableViewDelegate>
{
    NSInteger currnentIdx;
    
    
}
@property (nonatomic, strong) NSMutableArray *picArr; ///
@property (nonatomic, strong) NSMutableArray *arrSelected; ///
@property (nonatomic, strong) HWImagePickerSheet *imgPickerActionSheet; ///
@property (weak, nonatomic) IBOutlet UIButton *imageBtn1;
@property (weak, nonatomic) IBOutlet UIButton *imageBtn2;
@property (weak, nonatomic) IBOutlet UIButton *imageBtn3;
@property (weak, nonatomic) IBOutlet UILabel *headertitle;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *headertitleHeight;

@property (nonatomic, copy) NSString *imagPath1; ///
@property (nonatomic, copy) NSString *imagPath2; ///
@property (nonatomic, copy) NSString *imagPath3; ///
@end

@implementation RealNameViewController
- (IBAction)shenfengzhengzhangmianBtn:(id)sender {
    currnentIdx = 1;
    
    [self addNewImg];
}
- (IBAction)shenfengzhengFanMianBtn:(id)sender {
    currnentIdx = 2;
    
    [self addNewImg];
}
- (IBAction)shenfengzhengShouChiBtn:(id)sender {
    currnentIdx = 3;
    
    [self addNewImg];
}
#pragma mark - 选择图片
- (void)addNewImg{
    if (!_imgPickerActionSheet) {
        _imgPickerActionSheet = [[HWImagePickerSheet alloc] init];
        _imgPickerActionSheet.delegate = self;
    }
    if (self.picArr) {
//        _imgPickerActionSheet.arrSelected = self.arrSelected;
    }
    _imgPickerActionSheet.maxCount = 1;
    [_imgPickerActionSheet showImgPickerActionSheetInView:self];
}

- (void)getSelectImageWithALAssetArray:(NSArray *)ALAssetArray thumbnailImageArray:(NSArray *)thumbnailImgArray {
    self.arrSelected = [NSMutableArray arrayWithArray:ALAssetArray];
    //正方形缩略图 Array
    if (currnentIdx ==1) {
        for (UIImage *obj in thumbnailImgArray) {
            self.imagPath1 = [NSString saveImage:obj WithName:[NSString getTodaySS]];
        }
        if (thumbnailImgArray.count >0) {
            [self.picArr  removeAllObjects];
            [self.imageBtn1 setImage:thumbnailImgArray[0] forState:0];
            //     [self.imageBtn setCircleButton];
            //        self.cancelBtn.hidden = NO;
            //        self.cancelBtn.userInteractionEnabled = !self.cancelBtn.hidden;
            [self.picArr addObjectsFromArray:thumbnailImgArray];
        } else {
            //        self.cancelBtn.hidden = YES;
            //        self.cancelBtn.userInteractionEnabled = !self.cancelBtn.hidden;
            //        [self.imageBtn setImage:PXY_IMG(@"选择图片") forState:0];
        }
    } else  if (currnentIdx == 2) {
        for (UIImage *obj in thumbnailImgArray) {
            self.imagPath2 = [NSString saveImage:obj WithName:[NSString getTodaySS]];
        }
        if (thumbnailImgArray.count >0) {
            [self.picArr  removeAllObjects];
            [self.imageBtn2 setImage:thumbnailImgArray[0] forState:0];
            //     [self.imageBtn setCircleButton];
            //        self.cancelBtn.hidden = NO;
            //        self.cancelBtn.userInteractionEnabled = !self.cancelBtn.hidden;
            [self.picArr addObjectsFromArray:thumbnailImgArray];
        } else {
            //        self.cancelBtn.hidden = YES;
            //        self.cancelBtn.userInteractionEnabled = !self.cancelBtn.hidden;
            //        [self.imageBtn setImage:PXY_IMG(@"选择图片") forState:0];
        }
    } else{
        for (UIImage *obj in thumbnailImgArray) {
            self.imagPath3 = [NSString saveImage:obj WithName:[NSString getTodaySS]];
        }
        if (thumbnailImgArray.count >0) {
            [self.picArr  removeAllObjects];
            [self.imageBtn3 setImage:thumbnailImgArray[0] forState:0];
            //     [self.imageBtn setCircleButton];
            //        self.cancelBtn.hidden = NO;
            //        self.cancelBtn.userInteractionEnabled = !self.cancelBtn.hidden;
            [self.picArr addObjectsFromArray:thumbnailImgArray];
        } else {
            //        self.cancelBtn.hidden = YES;
            //        self.cancelBtn.userInteractionEnabled = !self.cancelBtn.hidden;
            //        [self.imageBtn setImage:PXY_IMG(@"选择图片") forState:0];
        }
        
    }
    
    
};

#pragma mark -----------<#name#>-------------------懒加载;
- (NSMutableArray *)picArr {
    if (!_picArr) {
        self.picArr = [NSMutableArray array];
    }
    return _picArr;
}

#pragma mark -----------<#name#>-------------------懒加载;
- (NSMutableArray *)arrSelected {
    if (!_arrSelected) {
        self.arrSelected = [NSMutableArray array];
    }
    return _arrSelected;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.tableFooterView = [UIView new];
    self.headertitle.text = @"单笔或累计交易额超过50000元后，需要进行实名认证才能继续交易。您需要提供身份证正反面、手持身份证照或有效的护照进行实名认证，认证成功后不可修改。";
    
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidLayoutSubviews {
    
    if (iPhone5) {
          self.headertitleHeight.constant = 70;
    } else{
          self.headertitleHeight.constant = 60;
    }
  
    [super viewDidLayoutSubviews];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    
    return 0;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
